<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

use app\common\model\ExchangePlatform;
use app\common\model\ExchangeTags;
use think\Db;


/**
 * 行情币种控制器
 */
class MarketCoin extends AdminBase
{
    
    /**
     * 行情币种列表
     */
    public function coinList()
    {
        
       // $where = $this->logiccoin->getWhere($this->param);

        $this->assign('list', $this->logiccoin->getcoinList($this->param, 'a.*', 'a.create_time desc'));
        $this->assign('coin', Db::name('coin_usdt')->select());
        $this->assign('tags', Db::name('exchange_platform')->where(['status'=>1])->select());
        $this->assign('param', $this->param);
        return $this->fetch('coin_list');
    }



    /**
     * 行情币种列表
     */
    public function coin_list1()
    {

        // $where = $this->logiccoin->getWhere($this->param);

        $this->assign('list', $this->logiccoin->getcoinList1($this->param, '*'));
        $this->assign('param', $this->param);
        return $this->fetch('coin_list1');
    }


    /**
     * 行情币种添加
     */
    public function coinAdd()
    {
        
        $this->coinCommon();

        return $this->fetch('coin_edit');
    }
    
    /**
     * 行情币种编辑
     */
    public function coinEdit()
    {
        
        $this->coinCommon();
        
        $info = $this->logiccoin->getcoinInfo(['symbol' => $this->param['symbol']]);

        
        $this->assign('info', $info);

        return $this->fetch('coin_edit');
    }
    
    /**
     * 行情币种添加与编辑通用方法
     */
    public function coinCommon()
    {
        
//      IS_POST && $this->jump($this->logiccoin->coinEdit($this->param));
        IS_POST && $this->jump($this->logiccoin->coinEdit($_POST));
        $this->assign('tags', ExchangePlatform::all(['status'=>1]));
        $this->assign('coin', Db::name('coin_usdt')->select());

    }
    


    

    
    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('QuotationCoin', $this->param));
    }

    /**
     * 数据状态设置
     */
    public function update_info()
    {

        $this->jump($this->logiccoin->update_info( $this->param));
    }


    /**
     * 隐藏/显示回帖
     */
    public function comment_update_info()
    {

        $this->jump($this->logiccoin->comment_update_info( $this->param));
    }


    /**
     * 行情币种标签添加
     */
    public function coinTagsAdd()
    {

        IS_POST && $this->jump($this->logiccoin->coinTagsEdit($this->param));

        return $this->fetch('coin_Tags_edit');
    }

    /**
     * 行情币种标签编辑
     */
    public function coinTagsEdit()
    {

        IS_POST && $this->jump($this->logiccoin->coinTagsEdit($this->param));

        $info = $this->logiccoin->getcoinTagsInfo(['id' => $this->param['id']]);

        $this->assign('info', $info);

        return $this->fetch('coin_tags_edit');
    }

    /**
     * 行情币种标签列表
     */
    public function coinTagsList()
    {

        $this->assign('list', $this->logiccoin->getcoinTagsList());

        return $this->fetch('coin_tags_list');
    }

    /**
     * 行情币种标签删除
     */
    public function coinTagsDel($id = 0)
    {

        $this->jump($this->logiccoin->coinTagsDel(['id' => $id]));
    }
}
